zpool create: report which device caused failure#18213
Open
chrislongros wants to merge 1 commit intoopenzfs:masterfrom
Open
zpool create: report which device caused failure#18213chrislongros wants to merge 1 commit intoopenzfs:masterfrom
chrislongros wants to merge 1 commit intoopenzfs:masterfrom
Conversation
298ce20 to
a22cd15
Compare
behlendorf
reviewed
Feb 13, 2026
Contributor
behlendorf
left a comment
There was a problem hiding this comment.
Thanks for working on this!
tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_errinfo_001_neg.ksh
Outdated
Show resolved
Hide resolved
a22cd15 to
cc184fe
Compare
f2bd62e to
e533157
Compare
tonyhutter
reviewed
Feb 26, 2026
tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_errinfo_001_neg.ksh
Outdated
Show resolved
Hide resolved
tonyhutter
reviewed
Feb 26, 2026
tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_errinfo_001_neg.ksh
Outdated
Show resolved
Hide resolved
When zpool create fails because a vdev is already in use, the error
message now identifies the specific device and the pool it belongs
to.
Before:
cannot create 'tank': one or more vdevs refer to the same device
After:
cannot create 'tank': device '/dev/sdb1' is part of
active pool 'rpool'
Add a spa_create_info field to spa_t to capture device-level
error information during vdev_label_init(), before vdev_close()
resets vdev state. When vdev_inuse() detects a conflict, the
device path and pool name (read from the on-disk label) are stored
in the nvlist. This is returned to userspace wrapped under
ZPOOL_CONFIG_CREATE_INFO, following the ZPOOL_CONFIG_LOAD_INFO
pattern used by zpool import. If the pool name is not available,
the device path alone is reported.
New ZTS test zpool_create_errinfo_001_neg verifies device-specific
error messages by creating duplicate loopback vdevs and checking
that the output names the device and the active pool.
Tested:
- Duplicate loopback vdevs correctly report the device and
active pool name in the error message
- Normal pool creation succeeds
- New ZTS test passes on all platforms
- Clean build with no warnings
Suggested-by: Brian Behlendorf
Signed-off-by: Christos Longros <chris.longros@gmail.com>
e533157 to
8a053f5
Compare
behlendorf
reviewed
Mar 3, 2026
|
|
||
| if ((ret = zfs_ioctl(hdl, ZFS_IOC_POOL_CREATE, &zc)) != 0) { | ||
|
|
||
| if (zpool_create_info(hdl, &zc)) { |
Contributor
There was a problem hiding this comment.
Now that we're going to have infrastructure to report more detailed errors in zpool create I suspect we'll want to make use of it in some of the other error cases. I've thrown together a completely untested commit which restructures things so we can access the nvlists where we need them. Can you take a look at 2c5fa0d, refine as needed, and then squash something that's actually tested in to this PR!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When
zpool createfails because a vdev is already in use, the error message does not identify which device caused the problem:This is frustrating when creating pools with many disks, as there is no way to tell which device is the culprit without manually checking each one.
Description
This patch adds device-specific error reporting so the message now identifies the problematic device and the pool it belongs to:
Implementation follows the
ZPOOL_CONFIG_LOAD_INFOpattern used byzpool import, as suggested in #18184:spa_create_infotospa_tto capture error info duringvdev_label_init(), beforevdev_close()resets vdev statevdev_inuse()detects a conflict, read the on-disk label to extract the pool name and store it with the device pathZPOOL_CONFIG_CREATE_INFOthrough the ioctlzc_nvlist_dstto userspacezpool_create_info()helper unwraps the nvlist and formats the device-specific error messageIf the pool name cannot be read from the label, the device path alone is reported as a fallback.
Testing
zpool_create_errinfo_001_negverifies the error message names the device and the active pool when creating a mirror with duplicate loopback vdevs (portable across Linux and FreeBSD)checkstylepassesSuggested-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Christos Longros <chris.longros@gmail.com>